library(gcookbook)
library(ggplot2)
library(grid)
data(heightweight)
heightweight[,c('sex','ageYear','heightIn')]
# 正常绘制
p1 <- ggplot(heightweight,aes(x=ageYear,y= heightIn,shape =sex,color = sex)) + 
  geom_point()
p1
# 设置自己的形状
p2 <- ggplot(heightweight,aes(x=ageYear,y= heightIn,shape =sex,color = sex)) + 
  geom_point() +
  scale_shape_manual(values = c(1,2)) + # 设置自己的形状
  scale_color_brewer(palette='Set1') # 设置自己的调色板
p2

# 一页多图
grid.newpage() # 铺开新画面
pushViewport(viewport(layout = grid.layout(1, 2))) # 页面布局
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y) # 布局安排
# 指定位置
print(p1, vp = vplayout(1, 1)) 
print(p2, vp = vplayout(1, 2))
